package com.tianqu.tms.www.car.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsActionNotTimeout;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.www.car.controller.FindCarController;

public class FindCarBrandListAction  extends TmsActionNotTimeout {
	private final int pageSize = 5;
	private Logger logger = Logger.getLogger(FindCarBrandListAction.class);
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response, UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		String p1 = request.getParameter("carStyleId");
		String p2 = request.getParameter("vendorId");
		String p3 = request.getParameter("pageNumber");
		int pageNumber = StringUtils.isNumeric(p3)?Integer.parseInt(p3):1;
		FindCarController controller = new FindCarController();
		request.setAttribute(TmsConstants.VIEWHELP,controller.FindCarBrandListController(p2,p1,pageNumber,pageSize));
		logger.debug(this.getClass().getName() + "#execute was completed.");
		return mapping.findForward(TmsConstants.SUCCESS);
	}

}
